// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import axios from 'axios'
import Vuex from 'vuex'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App'
import router from './router'
import store from './store/index'


Vue.use(ElementUI);
Vue.use(Vuex);
Vue.prototype.axios= axios
Vue.prototype.qs = require('qs')

Vue.config.productionTip = false
axios.defaults.withCredentials = true;//跨域请求的全局凭证
axios.defaults.baseURL = 'http://120.78.135.29:60901/';

window.onload = function(){
  router.push({ path: '/' });
  // window.location = window.location.href
};
// 全局 路由钩子函数
router.beforeEach((to,from,next)=>{
  //console.log(to);
  if(to.meta.Auth){//客户端需要登录状态
      if(store.state.isLogin){      
          next();
      }else{
          router.push({ path: '/' })
      }
  }else{//客户端不需要登录状态
      next();
  }
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
